package com.chinastock.demo.controller;

import com.chinastock.communication.BaseResponse;
import com.chinastock.demo.vo.ExceptionReqVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

/**
 * @author zhangfan.it
 * @date 2021/2/2
 */
@ConfigurationProperties(prefix ="application" )
@RestController
@EnableAutoConfiguration
@RequestMapping("/demo-webflux-log")
@Api(value = "webflux日志测试接口", tags = {"webflux日志测试接口"})
public class Controller {
    @ApiOperation(notes = "demo-webflux-log", value = "webflux日志测试接口")
    @RequestMapping(value = "/test", method = RequestMethod.POST)
    public Mono<BaseResponse<Void>> test(@RequestBody String input) {
        return Mono.just(new BaseResponse<>(true, "0000", "成功"));
    }

    @ApiOperation(notes = "测试异常日志", value = "测试异常日志")
    @RequestMapping(value = "/testException", method = RequestMethod.POST)
    public Mono<BaseResponse<Void>> testException(@RequestBody ExceptionReqVo reqVo) throws Exception{
        throw new Exception("");
    }
}
